/* const target = {
    message:'hello',
    get greeting(){
        return this.message;
    }
}
const handler = {
    get (target,prop){
        return Reflect.get(target,prop);
    }
}
let proxy = new Proxy(target,handler);
console.log(proxy.greeting) */

const target = {
    value:1,
    age:10,
    get doubleValue(){
        return this.value+this.age;
    }
}
const handler = {
    get(target,prop,receiver){//receiver = Proxy 对象
        if(prop === 'age'){
            return 20;
        }
        return Reflect.get(target,prop,receiver);
        //return target[prop];
    }
}
let proxy = new Proxy(target,handler);
console.log(proxy.age)//20
console.log(proxy.value)//1
console.log(proxy.doubleValue)//21